<style>
    .hidden {
        display: none;
    }
</style>
<div class="layui-form" lay-filter="layuiadmin-form-admin" style="padding: 20px 30px 0 0;">
    <!-- <div class="layui-form-item">
        <label class="layui-form-label">目录号</label>
        <div class="layui-input-inline">
            <script type="text/html" template>
                <input type="text" name="indexNo" value="{{ d.params.indexNo || '' }}" lay-verify="indexNo" autocomplete="off" class="layui-input">
            </script>
        </div>

    </div> -->
    <div class="layui-form-item">
        <label class="layui-form-label">产品名称</label>
        <div class="layui-input-inline">
            <script type="text/html" template>
                <input type="text" name="productName" value="{{ d.params.productName || '' }}" lay-verify="productName" autocomplete="off" class="layui-input">
            </script>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">规格</label>
            <div class="layui-input-inline">
                <script type="text/html" template>
                    <input type="text" name="standards" value="{{ d.params.standards || '' }}" autocomplete="off" class="layui-input">
                </script>
            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">名称</label>
        <div class="layui-input-inline">
            <script type="text/html" template>
                <input type="text" name="name" value="{{ d.params.name || '' }}" lay-verify="name" autocomplete="off" class="layui-input">
            </script>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">浏览数量</label>
        <div class="layui-input-inline">
            <script type="text/html" template>
                <input {{d.params.productId? 'disabled': '' }} type="number" name="viewCount" value="{{d.params.viewCount?'disabled':'' }}" lay-verify="viewCount" autocomplete="off" class="layui-input">
            </script>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">类别ID</label>
        <div class="layui-input-inline">
            <script type="text/html" template>
                <select name="categoryId" value="{{ d.params.categoryId || '' }}" id="categoryId" lay-verify="categoryId" lay-search="">

                </select>

            </script>
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">价格</label>
            <div class="layui-input-inline" style="width: 100px;">
                <script type="text/html" template>
                    <input type="text" name="price" value="{{ d.params.price || '' }}" lay-verify="price" autocomplete="off" class="layui-input">
                </script>
            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">是否热门</label>
        <div class="layui-input-block">
            <script type="text/html" template>
                <input type="checkbox" name="isHot" {{ d.params.isHot==1? 'checked': ''}} lay-verify="isHot" title="是">
            </script>
        </div>
    </div>
    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">简介</label>
        <div class="layui-input-block">
            <textarea id="demo" style="display: none;" value="{{ d.params.introduct || '' }}"></textarea>
        </div>
    </div>

    <div class="btn-one">
        <fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
            <legend>上传使用说明</legend>
        </fieldset>
        <div class="layui-upload-drag">
            <i id="test1" class="layui-icon"></i>
            <p>点击上传使用说明</p>
            <script type="text/html" template>
                <div class="{{d.params.productId?'':'layui-hide'}}" id="uploadDemoView1">
                    <hr>
                    <a class="{{d.params.useBook?'':'layui-hide'}}" id="chakan" href="{{ d.params.useBook || '' }}" style="max-width: 196px">下载</a>
                    <input class="hidden" name="useBook" value="{{ d.params.useBook || '' }}">
                </div>
            </script>
        </div>
    </div>
    <script type="text/html" template>
        <input name="productId" value="{{ d.params.productId || '' }}" class="hidden">
    </script>

    <div class="btn-one">
        <fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
            <legend>上传许可证</legend>
        </fieldset>
        <div class="layui-upload-drag" style="text-align: left;">
            <i class="layui-icon test2"></i>
            <p>点击上传许可证</p>
            <script type="text/html" template>
                <div class="{{d.params.productId?'':'layui-hide'}}" id="uploadDemoView2">
                    <hr>
                    <img src="{{ d.params.licence || '' }}" style="max-width: 196px" />
                    <input class="hidden" name="licence" value="{{ d.params.licence || '' }}">
                </div>
            </script>
        </div>
    </div>
    <div class="btn-one">
        <fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
            <legend>上传注册证</legend>
        </fieldset>
        <div class="layui-upload-drag" style="text-align: left;">
            <i class="layui-icon test3"></i>
            <p>点击上传注册证</p>
            <script type="text/html" template>
                <div class="{{d.params.productId?'':'layui-hide'}}" id="uploadDemoView3">
                    <hr>
                    <img src="{{ d.params.registeNo || '' }}" style="max-width: 196px" />
                    <input class="hidden" name="registeNo" value="{{ d.params.registeNo || '' }}">
                </div>
            </script>
        </div>
    </div>
    <div class="btn-one">
        <fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
            <legend>上传产品图片</legend>
        </fieldset>
        <div class="layui-upload-drag" style="text-align: left;">
            <i class="layui-icon test4"></i>
            <p>点击上传产品图片</p>
            <script type="text/html" template>
                <div class="{{d.params.productId?'':'layui-hide'}}" id="uploadDemoView4">
                    <hr>
                    <img src="{{ d.params.productImg || '' }}" style="max-width: 196px" />
                    <input class="hidden" name="productImg" value="{{ d.params.productImg || '' }}">
                </div>
            </script>
        </div>
    </div>
    <div class="btn-five" style=" margin: 30px 0px 0px 110px;">
        <div class="layui-input-inline">
            <input type="button" id="okbtn" lay-submit lay-filter="LAY-user-front-submit" value="确认" class="layui-btn" style="margin-bottom: 30px;">
        </div>
    </div>
</div>

<script>
    layui.use('upload', function() {
        var $ = layui.jquery,
            setter = layui.setter,
            admin = layui.admin,
            upload = layui.upload;

        //获取子菜单
        getmenu()

        function getmenu() {
            //取值
            var arr = sessionStorage.getItem('categoryId');
            admin.req({
                url: setter.request.baseUrl + "/product/admin/menu",
                data: {
                    parentId: 3
                },
                type: "get",
                done: function(res) {
                    if (res.code == 0) {
                        var html = "",
                            html1 = "";
                        html1 = "<option value=''>请选择</option>"
                        for (let i = 0; i < res.list.length; i++) {
                            html += "<option value=" + res.list[i].menuId + ">" + res.list[i].menuName + "</option>"
                        }
                        $("select[name='categoryId']").empty().append(html1 + html)
                        if (arr != "") {
                            $("select[name='categoryId'] option[value=" + arr + "]").attr("selected", true)
                        }
                        layui.form.render('select')
                    }
                },
            });
        }
        //上传文件   
        upload.render({
            elem: '#test1',
            url: setter.request.baseUrl + '/upload/admin/file',
            exts: 'txt|docx',
            accept: 'file',
            done: function(res) {
                layer.msg(res.message);
                layui.$('#uploadDemoView1').removeClass('layui-hide').find('a').attr('href', res.data.src);
                $("input[name='useBook']").val(res.data.src)
            }
        });
        //上传图片
        upload.render({
            elem: '.test2',
            url: setter.request.baseUrl + '/upload/admin/file',
            exts: 'jpg|png|jpeg',
            done: function(res) {
                layer.msg('上传成功');
                layui.$('#uploadDemoView2').removeClass('layui-hide').find('img').attr('src', res.data.src);
                $("input[name='licence']").val(res.data.src)
            }
        });
        upload.render({
            elem: '.test3',
            url: setter.request.baseUrl + '/upload/admin/file',
            exts: 'jpg|png|jpeg',
            done: function(res) {
                layer.msg('上传成功');
                layui.$('#uploadDemoView3').removeClass('layui-hide').find('img').attr('src', res.data.src);
                $("input[name='registeNo']").val(res.data.src)
            }
        });
        upload.render({
            elem: '.test4',
            url: setter.request.baseUrl + '/upload/admin/file',
            exts: 'jpg|png|jpeg',
            done: function(res) {
                layer.msg('上传成功');
                layui.$('#uploadDemoView4').removeClass('layui-hide').find('img').attr('src', res.data.src);
                $("input[name='productImg']").val(res.data.src)
            }
        });

    });
</script>